<?php
$unit = isset($_GET['u'])?$_GET['u']:null;
$email = isset($_GET['e'])?$_GET['e']:null;
$phone = isset($_GET['p'])?$_GET['p']:null;
$alias = isset($_GET['a'])?$_GET['a']:null;
$unit = trim($unit);
$email = trim($email);
$phone = trim($phone);
$alias = trim($alias);
if($unit==''||$email==''||$phone==''||$alias=='')return;
include_once 'constants.php';
logIt("login.php parm:",'after include');
$mysqli = new mysqli($hostname,$username,$password,$database);
$sql = 'SELECT a.pkey FROM loc_cust a, loc_unit b where b.pkey = fk_pkey_loc_cust '
	.'and unit = ? and email = ? and phone = ? and alias = ?';
logIt("login.php sql:",$sql);
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('isss',$unit,$email,$phone,$alias);
$rslt = $stmt->execute();
if($rslt){
	$stmt->bind_result($pkey);
	if($stmt->fetch()){
		$loginInfo = array($pkey);
		session_start();
		$_SESSION[$sessionLoginTag] = 1;
		$_SESSION[$sessionLoginInfoTag] = $loginInfo;
		echo '0';
	}
}
?>